Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rocket.chat/rest-typings

Package Overview
Dependencies
Maintainers
0
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rocket.chat/rest-typings

Package containing all Rocket.Chat rest endpoint definitions

  • 7.0.0
  • npm
  • Socket score

Version published
Weekly downloads
264
increased by2300%
Maintainers
0
Weekly downloads
 
Created
Source

@rocket.chat/rest-typings

Package containing all Rocket.Chat rest endpoint definitions

Contributing

Contributions are always welcome! However we have some recommendations.

  • Check if your implementation matches your definitions, a bad definition is worse than none.
  • Use the generic types we created for paging.
  • Create functions that assert properties (very useful for the backend)
  • Do tests to ensure that your assertions are correct.
  • Avoid incomplete and unknow typings

Good examples of what not to do:

If you have an endpoint that accepts name or id, both are not optional, one of them is required
    
    type EndPointTestGetParams = { name?: string; id?: string; } // WRONG!

    type EndPointTestGetParams = { name: string; } | { id: string; } // Better :)
If you have an endpoint that accepts name or id, both are not optional, one of them is required
    export const isEndPointTestGetParams = (props: any) is EndPointTestGetParams => 'name' in prop || 'id' in prop; // WRONG!

    // .... Better
    
    
    import Ajv from 'ajv';

    const ajv = new Ajv();
    const endPointTestGetParams = {
        oneOf: [
            {
                type: 'object',
                properties: {
                    name: {
                        type: 'string',
                    },
                },
                required: ['name'],
                additionalProperties: false,
            },
            {
                type: 'object',
                properties: {
                    id: {
                        type: 'string',
                    },
                },
                required: ['id'],
                additionalProperties: false,
            },
        ],
    };

    export const isEndPointTestGetParams = ajv.compile<EndPointTestGetParams>(endPointTestGetParams);

Optimizations

we use interfaces to register endpoints, so if you use a custom version, or miss an endpoint, you don't necessarily need to recompile the code, you can do it in your own code

    declare module '@rocket.chat/rest-typings' {
        interface Endpoints {
            'custom/endpoint': {
                GET: (params: PaginatedRequest<{ query: string }>) => PaginatedResult<{
                    some: string[];
                }>;
            };
        }
    }

License

MIT

FAQs

Package last updated on 01 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc